<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JSON</title>
    <script src="../js/jquery-1.12.4.js"></script>
</head>
<body>
<h1>我是json</h1>
<input type="button" onclick="doGet()" value="get请求">
<input type="button" onclick="doPost()" value="post请求">
</body>
<script>
    function doGet() {
        $.ajax({
            url:"/json/findById?id=1",
            type: "get",
            success:function(data){
                console.log(data);
            },
            error:function(data) {
                console.log(data);
            }
        });

    }


    function doPost() {
        $.ajax({
            url:"/json/add",
            type: "post",
            data: "{\"id\":4,\"name\":\"awdawawd\",\"sex\": \"男\", \"birthday\": \"2022-09-29\"}",
            contentType: "application/json",
            success:function(data){
                console.log(data);
            },
            error:function(data) {
                console.log(data);
            }
        });
    }


</script>
</html>